from datetime import timedelta

import logging
from redis import StrictRedis


class Config(object):
    DEBUG = True
    SECRET_KEY = "SSHFJSHF"
    # 数据库配置信息
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:mysql@localhost:3306/info36"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True #每当改变数据的内容之后,在视图函数结束的时候都会自动提交

    #redis配置信息
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    #session配置信息
    SESSION_TYPE = "redis"
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    PERMANENT_SESSION_LIFETIME = timedelta(days=2)

    LEVEL_NAME = logging.DEBUG

class DeveloConfig(Config):
    pass

class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR

class TestConfig(Config):
    pass

config_dict = {
    "develop":DeveloConfig,
    "product":ProductConfig,
    "test":TestConfig
}